<?php 
	$id = $_GET['id']; 
	$kk = $_GET['kk'];
	$sql="select * from penduduk p inner join agama a on p.id_agama = a.id_agama inner join pendidikan pd on p.id_pendidikan = pd.id_pendidikan inner join pekerjaan pk on p.id_pekerjaan = pk.id_pekerjaan inner join status_nikah s on p.id_status = s.id_status inner join hub_keluarga h on p.id_hub_keluarga = h.id_hub_keluarga where p.id_penduduk=$id";
	$qry=mysql_query($sql);
	$hasil = mysql_fetch_array($qry);
	$tgl = explode("-","$hasil[tgl_lahir]");
?>
<div id=tiga_ba>
	<div id=tiga_baa>Ubah Data Penduduk</div>
	<div id=tiga_bab></div>
	<div class=clear></div>
</div>
            
<form action="utama.php?module=mod_penduduk&act=update" onsubmit="return gsValidate(nik|nama|tempat_lahir|tgl|bln|thn|paspor|kitas|ayah|ibu','NIK Harus Diisi|Nama Harus Diisi|Tempat Lahir Harus Diisi|Tanggal Lahir Harus Dipilih|Bulan Lahir Harus Dipilih|Tahun Lahir Harus Dipilih|Nomer Paspor Harus Diisi|Nomer KITAS Harus Diisi|Nama Ayah Harus Diisi|Nama Ibu Harus Diisi','required_numeric|required|required|required|required|required|required|required|required|required');" method="post" enctype="multipart/form-data">
	<table style="margin: 10px 15px 10px 15px;">
		<tr>
			<td>ID KK</td>
			<td width="300">
				<input name="kk" type="text" id="kk" value="<? echo $hasil['id_kk']; ?>" class="input2"/>
				<input name="kode" type="hidden" id="kode" value="<? echo $hasil['id_penduduk']; ?>" class="input2"/>
			</td>
			<td>Agama</td>
			<td>
				<?php Ubah Data_kombo("agama","agama","$hasil[id_agama]","input2"); ?>
			</td>
		</tr>
		<tr>
			<td>NIK</td>
			<td>
				<input name="nik" type="text" id="nik" value="<?php echo $hasil['nik']; ?>" class="input2"/>
			</td>
			<td>Pendidikan</td>
			<td>
				<?php Ubah Data_kombo("pendidikan","pendidikan","$hasil[id_pendidikan]","input2"); ?>
			</td>
		</tr>
		<tr>
			<td>Nama</td>
			<td>
				<input name="nama" type="text" id="nama" value="<?php echo $hasil['nama']; ?>" class="input2"/>
			</td>
			<td>Pekerjaan</td>
			<td>
				<?php Ubah Data_kombo("pekerjaan","pekerjaan","$hasil[id_pekerjaan]","input2"); ?>
			</td>
		</tr>
		<tr>
			<td>Jenis Kelamin</td>
			<td>
				<select name="jk" type="text" id="jk" class="input2"/>
					<?php
						if($hasil['jk'] == 'L'){
							$l = "selected";
						}else{
							$p = "selected";
						}
						echo "<option value=L $l>Laki-laki</option>
							<option value=P $p>Perempuan</option>";
					?>
				</select>
			</td>
			<td>Status</td>
			<td>
				<?php Ubah Data_kombo("status","status_nikah","$hasil[id_status]","input2"); ?>
			</td>
		</tr>
		<tr>
			<td>Tempat Lahir</td>
			<td>
				<input name="tempat_lahir" type="text" id="tempat_lahir" value="<?php echo $hasil['tempat_lahir']; ?>" class="input2"/>
			</td>
			<td>Hubungan Keluarga</td>
			<td>
				<?php Ubah Data_kombo("keluarga","hub_keluarga","$hasil[id_hub_keluarga]","input2"); ?>
			</td>
		</tr>
		<tr>
			<td>Tanggal Lahir</td>
			<td>
				<select name="tgl" id="tgl" class="input1">
					<option value="">Tgl</option>
					<?php
						for($i=1;$i<=31;$i++){
							if($i == $tgl[2]){
								$s = "selected";
							}else{
								$s = "";
							}
							echo "<option value=$i $s>$i</option>";
						}
					?>
				</select>
				<select name="bln" id="bln" class="input1">
					<option value="">Bln</option>
					<?php
						for($i=1;$i<=12;$i++){
							if($i == $tgl[1]){
								$s = "selected";
							}else{
								$s = "";
							}
							echo "<option value=$i $s>$i</option>";
						}
					?>
				</select>
				<select name="thn" id="thn" class="input1">
					<option value="">Tahun</option>
					<?php
						for($i=1900;$i<=2020;$i++){
							if($i == $tgl[0]){
								$s = "selected";
							}else{
								$s = "";
							}
							echo "<option value=$i $s>$i</option>";
						}
					?>
				</select>
			</td>
			<td>Ayah</td>
			<td>
				<input name="ayah" type="text" id="ayah" value="<?php echo $hasil['ayah']; ?>" class="input2"/>
			</td>
		</tr>
		<tr>
			<td>Kewarganegaraan</td>
			<td>
				<select name="kewarganegaraan" id="kewarganegaraan" class="input2">
					<?php
						if($hasil['kewarganegaraan'] == 'WNI'){
							$wni = "selected";
						}else{
							$wna = "";
						}
						echo "<option value='WNI' $wni>WNI</option>
							<option value='WNA' $wna>WNA</option>";
					?>
				</select>
			</td>
			<td>Ibu</td>
			<td>
				<input name="ibu" type="text" id="ibu" value="<?php echo $hasil['ibu']; ?>" class="input2"/>
			</td>
		</tr>
		<tr>
			<td>No Paspor</td>
			<td>
				<input name="paspor" type="text" id="paspor" value="<?php echo $hasil['nopaspor']; ?>" class="input2"/>
			</td>
			<td>Status</td>
			<td>
				<select name="miskin" type="text" id="miskin" class="input2"/>
					<?php
						if($hasil['is_miskin'] == 'Y'){
							$y = "selected";
						}else{
							$n = "";
						}
						echo "<option value=Y $y>Miskin</option>
							<option value=N $n>Tidak Miskin</option>";
					?>
				</select>
			</td>
		</tr>
		<tr>
			<td>No. KITAS</td>
			<td>
				<input name="kitas" type="text" id="kitas" value="<?php echo $hasil['nokitas']; ?>" class="input2"/>
			</td>
			<td>Peserta BPJS</td>
			<td>
				<input type="radio" name="bpjs" value="Y">Ya
				<input type="radio" name="bpjs" value="N" checked>Tidak
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td><input name="submit" type="submit" class="button" value="Ubah" /></td>
		</tr>
	</table>                
</form>		
            
        